<style itemscope>
    .layui-form-label.required:before {
        /* 这种写法也可以*/
        content: ' *';
        color: red;
    }

    .addProductionPlanForm-title .title,
    .examineProductionPlanForm-title .title {
        display: inline-block;
        margin: 20px;
        font-size: 16px;
        font-weight: bold;
        color: #333333;
        line-height: 19px;
        position: relative;
        padding: 6px 0 19px 0;
    }

    .addProductionPlanForm-title .title:after,
    .examineProductionPlanForm-title .title:after {
        content: '';
        display: block;
        position: absolute;
        left: 0;
        bottom: 0;
        width: calc(100% + 6px);
        height: 3px;
        background: #0A8B0A;
    }

    .open-form .layui-input-block {
        margin-left: 115px;
    }
</style>
<script type="text/javascript" src="../../../admin/assets/js/pdfobject.min.js"></script>
<!-- 表单弹窗 -->
<form lay-filter="taskQualityRecordForm" class="layui-form open-form">
    <div class="open-model">
        <div class="open-auto">
            <div class="layui-form-item layui-row">
                <div class="layui-col-md3">
                    <label class="layui-form-label w-auto required">样品编码：</label>
                    <div class="layui-input-block">
                        <input id="code" disabled name="code" placeholder="样品编码" type="text" class="layui-input"
                            autocomplete="off" />
                    </div>
                </div>
                <div class="layui-col-md3">
                    <label class="layui-form-label w-auto">任务单编号：</label>
                    <div class="layui-input-block">
                        <input id="taskCode" disabled name="taskCode" placeholder="任务单编号" type="text"
                            class="layui-input" autocomplete="off" />
                    </div>
                </div>
                <div class="layui-col-md3">
                    <label class="layui-form-label w-auto">所属开工单：</label>
                    <div class="layui-input-block">
                        <input id="workCode" disabled name="workCode" placeholder="所属开工单" type="text"
                            class="layui-input" autocomplete="off" />
                    </div>
                </div>
                <div class="layui-col-md3">
                    <label class="layui-form-label w-auto">所属计划：</label>
                    <div class="layui-input-block">
                        <input id="planCode" disabled name="planCode" placeholder="所属计划" type="text" class="layui-input"
                            autocomplete="off" />
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-row">
                <div class="layui-col-md3">
                    <label class="layui-form-label w-auto">质检性质：</label>
                    <div class="layui-input-block">
                        <input id="qualityTestingNatureName" disabled name="qualityTestingNatureName" placeholder="质检性质"
                            type="text" class="layui-input" autocomplete="off" />
                    </div>
                </div>
                <div class="layui-col-md3">
                    <label class="layui-form-label w-auto">质检分类：</label>
                    <div class="layui-input-block">
                        <input id="categoryName" disabled name="categoryName" placeholder="质检分类" type="text"
                            class="layui-input" autocomplete="off" />
                    </div>
                </div>
                <div class="layui-col-md3">
                    <label class="layui-form-label w-auto">检测状态：</label>
                    <div class="layui-input-block">
                        <input id="statusName" disabled name="statusName" placeholder="检测状态" type="text"
                            class="layui-input" autocomplete="off" />
                    </div>
                </div>
                <div class="layui-col-md3">
                    <label class="layui-form-label w-auto required">判断结果：</label>
                    <div class="layui-input-block">
                        <input id="qualityTestingResultName" disabled name="qualityTestingResultName" placeholder="判断结果"
                            type="text" class="layui-input" autocomplete="off" />
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-row">
                <div class="layui-col-md3">
                    <label class="layui-form-label w-auto required">质检备注：</label>
                    <div class="layui-input-block">
                        <input id="remark" disabled name="remark" placeholder="请输入数量" type="text" class="layui-input"
                            autocomplete="off" />
                    </div>
                </div>
                <div class="layui-col-md3">
                    <label class="layui-form-label w-auto required">上传图片：</label>
                    <div class="layui-input-block">
                        <img class="layui-upload-img" id="uploadPreview" style="max-width: 200px;">
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-row">
                <div class="layui-tab" lay-filter="test-handle" lay-allowclose="true">
                    <ul class="layui-tab-title">
                        <li class="layui-this">任务时间线</li>
                        <li lay-id="BOMGUIHUA">样品检测结果</li>
                    </ul>
                    <div class="layui-tab-content">
                        <div class="layui-tab-item layui-show">
                            <div class="layui-timeline">
                                <div class="layui-timeline-item">
                                    <i class="layui-icon layui-timeline-axis"></i>
                                    <div class="layui-timeline-content layui-text">
                                        <h3 class="layui-timeline-title">创建任务<span id="createTaskTime">2013</span></h3>
                                        <p>
                                            <label class="layui-form-label w-auto">作业人：</label>
                                        <div class="layui-input-block">
                                            <input id="createName" style="border: none" readonly="readonly"
                                                name="createName" type="text" class="layui-input" autocomplete="off" />
                                        </div>
                                        </p>
                                        <p>
                                            <!-- <label class="layui-form-label w-auto">所属岗位：</label>
                                        <div class="layui-input-block">
                                            <input id="createPostName" style="border: none" readonly="readonly"
                                                   name="createPostName" type="text"
                                                   class="layui-input"
                                                   autocomplete="off"/>
                                        </div>
                                        </p>
                                        <p>
                                            <label class="layui-form-label w-auto">所属部门：</label>
                                        <div class="layui-input-block">
                                            <input id="createDepName" style="border: none" readonly="readonly"
                                                   name="createDepName"
                                                   type="text"
                                                   class="layui-input"
                                                   autocomplete="off"/>
                                        </div>
                                        </p> -->
                                    </div>
                                </div>
                                <div class="layui-timeline-item">
                                    <i class="layui-icon layui-timeline-axis"></i>
                                    <div class="layui-timeline-content layui-text">
                                        <h3 class="layui-timeline-title">认领任务<span id="getTaskTime">2013</span></h3>
                                        <p>
                                            <label class="layui-form-label w-auto">认领人：</label>
                                        <div class="layui-input-block">
                                            <input id="getName" style="border: none" readonly="readonly" name="getName"
                                                type="text" class="layui-input" autocomplete="off" />
                                        </div>
                                        </p>
                                        <p>
                                            <label class="layui-form-label w-auto">所属岗位：</label>
                                        <div class="layui-input-block">
                                            <input id="getPostName" style="border: none" readonly="readonly"
                                                name="getPostName" type="text" class="layui-input" autocomplete="off" />
                                        </div>
                                        </p>
                                        <p>
                                            <label class="layui-form-label w-auto">所属部门：</label>
                                        <div class="layui-input-block">
                                            <input id="getDepName" style="border: none" readonly="readonly"
                                                name="getDepName" type="text" class="layui-input" autocomplete="off" />
                                        </div>
                                        </p>
                                    </div>
                                </div>
                                <div class="layui-timeline-item">
                                    <i class="layui-icon layui-timeline-axis"></i>
                                    <div class="layui-timeline-content layui-text">
                                        <h3 class="layui-timeline-title">检出结果<span id="checkTaskTime">2013</span></h3>
                                        <p>
                                            <label class="layui-form-label w-auto">检出人：</label>
                                        <div class="layui-input-block">
                                            <input id="checkName" style="border: none" readonly="readonly"
                                                name="checkName" type="text" class="layui-input" autocomplete="off" />
                                        </div>
                                        </p>
                                        <p>
                                            <label class="layui-form-label w-auto">所属岗位：</label>
                                        <div class="layui-input-block">
                                            <input id="checkPostName" style="border: none" readonly="readonly"
                                                name="checkPostName" type="text" class="layui-input"
                                                autocomplete="off" />
                                        </div>
                                        </p>
                                        <p>
                                            <label class="layui-form-label w-auto">所属部门：</label>
                                        <div class="layui-input-block">
                                            <input id="checkDepName" style="border: none" readonly="readonly"
                                                name="checkDepName" type="text" class="layui-input"
                                                autocomplete="off" />
                                        </div>
                                        </p>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-tab-item" id="bom_info">
                            <div class="layui-form-item layui-row" id="yiwuyijian">
                                <table class="layui-table" id="addQualityItemTableList"
                                    lay-filter="addQualityItemTableList" style="margin: 1px 0 10px;"></table>
                            </div>
                            <div class="layui-form-item layui-row" id="jianyi">
                                <table class="layui-table" id="jianyiTableList" lay-filter="jianyiTableList"
                                    style="margin: 1px 0 10px;"></table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-form-item text-right pd-20">
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
        </div>
    </div>
</form>

<!--选择质检任务单-->
<script type="text/html" id="selectQualityTaskTemplate">
    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-card-body">
                <!-- 头部操作栏 -->
                <div class="layui-form toolbar">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label w-auto">质检任务单编号：</label>
                            <div class="layui-input-inline mr0" style="width: 240px;">
                                <input name="code" class="layui-input" type="text" placeholder="质检任务编号"/>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button class="layui-btn icon-btn" lay-filter="selectTheWorkProcessFormSubSearchLog"
                                    lay-submit style="padding: 0 24px;">
                                搜索
                            </button>
                            <button id="selectTaskQualityClose" class="layui-btn icon-btn">确认选择</button>
                        </div>
                    </div>
                </div>
                <!-- 表格 -->
                <table class="layui-table" id="selectQualityTaskTable"
                       lay-filter="selectQualityTaskTable"></table>
            </div>
        </div>
    </div>
</script>

<script type="text/html" id="viewAttachmentHtml">
    <div id="example1" style="height: 100%;"></div>
</script>

<script type="text/html" id="qualityItemTableBar">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detection">检测</a>
</script>

<!-- js部分 -->
<script>
    layui.use(['layer', 'form', 'table', 'laydate', 'admin', 'laytpl', 'upload', 'config'], async function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var config = layui.config;
        var upload = layui.upload;
        var table = layui.table;
        var admin = layui.admin;
        var form = layui.form;

        let addQualityItemTableList = [];
        let initData = [];
        let jianyiTableList = []
        const warehouseRes = await admin.reqPro(
            "enterprisecab/warehouse/admin/warehouse/list",
            { limit: 9999, status: 0 }
        );
        const warehouseList = warehouseRes.data;
        //选择开工单
        let templateData = admin.getTempData("taskQualityRecordData");

        //修改
        if (templateData) {
            
            //显示值
            form.val("taskQualityRecordForm", templateData);
            $('#uploadPreview').attr('src', templateData.paperSlipPic);
            admin.reqSync('production/quality/admin/taskQualityRecord/getDetailRecordValue', {
                taskId: templateData.taskId,
                recordDetailId: templateData.id
            },
                res => {
                    if (res.code == 200) {
                        if(res.data.sampleCode.indexOf('SIMP')>-1){
                            $("#yiwuyijian").hide();
                        }else{
                            $("#jianyi").hide();
                        }
                        addQualityItemTableList = res.data.detailValueInfoVos;
                        jianyiTableList = [
                            {
                                result: "合格",
                                simpleNum:res.data.okQuantity,
                                warehouse:res.data.okWarehouseType,
                            },
                            {
                                result: "返工",
                                simpleNum:res.data.returnQuantity,
                                warehouse:res.data.returnWarehouseType,
                            },
                            {
                                result: "报废",
                                simpleNum:res.data.ngQuantity,
                                warehouse:res.data.ngWarehouseType,
                            }
                        ]
                        table.reload('addQualityItemTableList', {
                            data: addQualityItemTableList
                        });
                    }
                }, 'GET');

            admin.req('production/quality/admin/workOrderQualityTask/getTaskDetailRecord', { taskId: templateData.taskId }, function (res) {
                if (res.code == 200) {
                    //初始化时间节点
                    // <span id="createTaskTime">2013</span>
                    $("#createTaskTime").html(res.data.qualityTimeDetailInfoVo.createTime);
                    $("#getTaskTime").html(res.data.qualityTimeDetailInfoVo.getTime);
                    $("#checkTaskTime").html(res.data.qualityTimeDetailInfoVo.checkTime);

                    $("#createName").val(res.data.qualityTimeDetailInfoVo.createName);
                    $("#getName").val(res.data.qualityTimeDetailInfoVo.getName);
                    $("#checkName").val(res.data.qualityTimeDetailInfoVo.checkName);

                    $("#createPostName").val(res.data.qualityTimeDetailInfoVo.createPostName);
                    $("#getPostName").val(res.data.qualityTimeDetailInfoVo.getPostName);
                    $("#checkPostName").val(res.data.qualityTimeDetailInfoVo.checkPostName);

                    $("#getDepName").val(res.data.qualityTimeDetailInfoVo.getDepName);
                    $("#createDepName").val(res.data.qualityTimeDetailInfoVo.createDepName);
                    $("#checkDepName").val(res.data.qualityTimeDetailInfoVo.checkDepName);
                } else {
                    layer.msg(res.msg, { icon: 2 });
                }
            }, 'GET');

            //初始化质检项目
            let addQualityDetailRecordTable = table.render({
                elem: '#addQualityItemTableList',
                data: addQualityItemTableList,
                id: 'addQualityItemTableList',
                limit: 9999,
                cols: [[
                    { type: 'numbers', title: '序号', align: 'center' }
                    , { field: 'processQualityName', title: '检测项目', align: 'center', width: 200 }
                    , { field: 'utensil', title: '检测器具', align: 'center' }
                    , { field: 'way', title: '检验方法', align: 'center' }
                    , { field: 'standard', title: '标准/规格', align: 'center' }
                    , { field: 'processQualityValueName', edit: 'text', title: '检测结果(必填)', align: 'center' }
                    , { field: 'remark', edit: 'text', title: '质检备注(选填)', align: 'center' }
                    , { field: 'fileName', edit: 'text', title: '图片名称', align: 'center' }
                    , { field: 'fileUrl', edit: 'text', title: '图片地址', align: 'center' }
                    , { align: 'center', toolbar: '#productDetailValueTableBar', title: '操作', width: 300 }
                ]]
            });
            table.render({
                elem: "#jianyiTableList",
                data: [...jianyiTableList],
                id: "jianyiTableList",
                limit: 9999,
                // data: [
                //     {
                //         result: "合格",
                //     },
                //     {
                //         result: "返工",
                //     },
                //     {
                //         result: "报废",
                //     },
                // ],
                cols: [
                    [
                        { type: "numbers", title: "序号", align: "center" },
                        {
                            field: "result",
                            title: "质检结果",
                            align: "center",
                        },
                        {
                            field: "simpleNum",
                            title: "数量",
                            align: "center",
                        },
                        {
                            field: "warehouse",
                            title: "入库仓库类型",
                            align: "center",
                            templet: admin.setTableSelect(
                                "warehouse",
                                warehouseList.map((v) => {
                                    v.label = v.name + "(" + v.warehouseTypeName + ")";
                                    v.value = v.id;
                                    return v;
                                }),true
                            ),
                        },
                    ],
                ],
                done: () => {
                    $("#jianyiTableList .layui-table-body").css("overflow", "visible");
                    $("#jianyiTableList .layui-table-box").css("overflow", "visible");
                    $("#jianyiTableList .layui-table-view").css("overflow", "visible");
                },
            });
        }

    });
</script>